import 'dart:convert';

import 'package:ichinesereader/models/student/ProfileStudent.dart';

ProfileParent profileParentFromJson(String str) =>
    ProfileParent.fromJson(json.decode(str));

String profileParentToJson(ProfileParent data) => json.encode(data.toJson());

class ProfileParent {
  ProfileParent({
    this.userId,
    this.userName,
    this.email,
    this.firstName,
    this.lastName,
    this.role,
    this.disabled,
    this.timestampDisabled,
    this.timestampEnabled,
    this.timestampCreated,
    this.timestampPasswordChanged,
    this.profileImageUrl,
    this.settings,
    this.deleted,
    this.lastLoggedIn,
    this.lastLogIn,
    this.children,
    this.theme,
    this.lang,
  });

  String? userId;
  String? userName;
  String? email;
  String? firstName;
  String? lastName;
  List<String>? role;
  bool? disabled;
  dynamic timestampDisabled;
  dynamic timestampEnabled;
  dynamic timestampCreated;
  int? timestampPasswordChanged;
  dynamic profileImageUrl;
  dynamic settings;
  bool? deleted;
  int? lastLoggedIn;
  dynamic lastLogIn;
  List<ProfileStudent>? children;
  int? theme;
  int? lang;

  factory ProfileParent.fromJson(Map<String, dynamic> json) => ProfileParent(
        userId: json["userId"],
        userName: json["userName"],
        email: json["email"],
        firstName: json["firstName"],
        lastName: json["lastName"],
        role: List<String>.from(json["role"].map((x) => x)),
        disabled: json["disabled"],
        timestampDisabled: json["timestampDisabled"],
        timestampEnabled: json["timestampEnabled"],
        timestampCreated: json["timestampCreated"],
        timestampPasswordChanged: json["timestampPasswordChanged"],
        profileImageUrl: json["profileImageUrl"],
        settings: json["settings"],
        deleted: json["deleted"],
        lastLoggedIn: json["lastLoggedIn"],
        lastLogIn: json["lastLogIn"],
        children: json["children"] != null
            ? List<ProfileStudent>.from(
                json["children"].map((x) => ProfileStudent.fromJson(x)))
            : null,
        theme: json["theme"],
        lang: json["lang"],
      );

  Map<String, dynamic> toJson() => {
        "userId": userId,
        "userName": userName,
        "email": email,
        "firstName": firstName,
        "lastName": lastName,
        "role": List<dynamic>.from(role!.map((x) => x)),
        "disabled": disabled,
        "timestampDisabled": timestampDisabled,
        "timestampEnabled": timestampEnabled,
        "timestampCreated": timestampCreated,
        "timestampPasswordChanged": timestampPasswordChanged,
        "profileImageUrl": profileImageUrl,
        "settings": settings,
        "deleted": deleted,
        "lastLoggedIn": lastLoggedIn,
        "lastLogIn": lastLogIn,
        "children": children != null
            ? List<dynamic>.from(children!.map((x) => x.toJson()))
            : null,
        "theme": theme,
        "lang": lang,
      };
}
